//
//  IMTCANManager.h
//  ROCOMO
//
//  Created by Kyle Sun on 5/13/16.
//  Copyright © 2016 ROCOMO. All rights reserved.
//

#import <CoreBluetooth/CoreBluetooth.h>
#import "IMTCANMessageFactory.h"
#import "KSBLEManager.h"

extern const NSInteger kIMTCANMaxPacketSize;
extern NSString * const IMTCANManagerErrorDomain;

typedef void(^IMTCANMessageCompletionBlock)(NSError *error, NSData *responseData);

@interface IMTCANManager : NSObject

/// 添加车子主动发送数据的处理
@property (nonatomic,  copy) IMTCANMessageCompletionBlock carDataBlock;
@property (nonatomic, strong) NSString *carDataKey;

+ (IMTCANManager *)sharedInstance;

/// 发送数据
- (void)sendMessage:(IMTCANMessage *)message completion:(IMTCANMessageCompletionBlock)completion;
/// 发送数据
- (void)sendMessage:(IMTCANMessage *)message withTimeOut:(CGFloat)timeOut completion:(IMTCANMessageCompletionBlock)completion;

/// 发送数据无需结果 -- 不入列
- (void)sendMessage:(IMTCANMessage *)message;

/// 添加消息回调block
- (void)addCompletionBlock:(IMTCANMessageCompletionBlock)block forKey:(NSString *)key;
/// 移除消息回调block
- (void)removeCompletionBlockForKey:(NSString *)key;
/// 清除消息
- (void)clearMessages;

/// 添加车子主动发送数据的处理
- (void)addReceiveDataFromCarWithCompletionBlock:(IMTCANMessageCompletionBlock)block forKey:(NSString *)key;

@end
